package jp.ac.kobe_u.cs.cream;

import jp.ac.kobe_u.cs.cream.*;
import java.util.*;

public class Trail {
    private Stack trail = new Stack();

    public int size() {
	return trail.size();
    }

    public void push(Variable v) {
	Object pair[] = { v, v.getDomain() };
	trail.push(pair);
    }

    public void undo(int size0) throws EmptyStackException {
	for (int size = trail.size(); size > size0; size--) {
	    Object pair[] = (Object[])trail.pop();
	    Variable v = (Variable)pair[0];
	    v.setDomain((Domain)pair[1]);
	}
    }
}
